/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						script_variable_expression.h

	$Header: /heroes4/script_variable_expression.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_VARIABLE_EXPRESSION_H_INCLUDED )
#define SCRIPT_VARIABLE_EXPRESSION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <iosfwd>
#include <string>

#include "abstract_script_expression.h"
#include "streambuf_operators.h"

// --------------------------------------------------------------------------
// t_script_variable_expression class template
// --------------------------------------------------------------------------

template < typename t_base >
class t_script_variable_expression : public t_base
{
public:
	// Member functions
	std::string const &	get_name() const;

	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;

private:
	// Data members
	std::string	m_name;
};

// --------------------------------------------------------------------------
// t_script_variable_expression members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
template < typename t_base >
inline std::string const &
t_script_variable_expression< t_base >::get_name() const
{
	return m_name;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
template < typename t_base >
bool t_script_variable_expression< t_base >::read_from_map(
	std::streambuf &	stream,
	int					format_version )
{
	return read_string16( stream, m_name );
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
template < typename t_base >
bool t_script_variable_expression< t_base >::read( std::streambuf& stream, int version )
{
	return read_string16( stream, m_name );
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
template < typename t_base >
bool t_script_variable_expression< t_base >::write( std::streambuf& stream ) const
{
	if (!t_base::write( stream )) 
		return false;
	
	return write_string16( stream, m_name );
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// t_script_numeric_variable type
// --------------------------------------------------------------------------


class t_script_numeric_variable 
	: public t_script_variable_expression< t_abstract_script_numeric_expression >	
{
public:
	virtual t_result	evaluate(t_expression_context_global const& context) const;
};

SPECIALIZE_SCRIPT_NUMERIC_EXPRESSION( k_script_numeric_variable, t_script_numeric_variable );

// --------------------------------------------------------------------------
// t_script_boolean_variable type
// --------------------------------------------------------------------------

class t_script_boolean_variable
	: public t_script_variable_expression < t_abstract_script_boolean_expression >
{
	virtual t_result	evaluate(t_expression_context_global const& context) const;
};

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_variable, t_script_boolean_variable );

#endif // !defined( SCRIPT_VARIABLE_EXPRESSION_H_INCLUDED )
